Skip to content

fix(dashboard): Remove 308 redirect when creating new dashboards - #28754

Closed
ericsong wants to merge 1 commit into
apache:masterfrom
ericsong:master
Closed

ericsong wants to merge 1 commit into
apache:masterfrom
ericsong:master

Conversation

@ericsong

@ericsong ericsong commented May 29, 2024 •

Copy link
Copy Markdown

User description

SUMMARY

Currently, a request for a new dashboard (hitting /dashboard/new) will respond with a 308 permanent redirect because the UI hits /dashboard/new even though the backend exposes /dashboard/new/


Flask handles this case by responding with a 308 to the exposed version https://flask-cn.readthedocs.io/en/stable/api/#flask.Flask.route.

This PR changes routes in the frontend from /dashboard/new to /dashboard/new/ so that requests can be made without a 308 redirect.

In our infrastructure setup, there's a problem with the 308 redirect and it points to an invalid address. I believe others have seen this problem as well in this issue #20577.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Reproduction Steps

  1. Hard refresh to remove cached response to /dashboard/new redirection
  2. Create a new dashboard

Before
Screenshot 2024-05-28 at 9 05 32 PM

After
Screenshot 2024-05-28 at 9 20 03 PM

TESTING INSTRUCTIONS

See Reproduction Steps in section above

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

CodeAnt-AI Description

Use /dashboard/new/ for creating dashboards to avoid 308 redirects

What Changed

  • Dashboard creation links and buttons now navigate directly to /dashboard/new/ instead of /dashboard/new, so the browser goes straight to the backend endpoint without a 308 redirect
  • Welcome/empty-state, right-hand menu, dashboard table, and dashboard list UI paths were updated so all "Create Dashboard" entry points use the trailing-slash URL
  • Frontend tests were updated to expect /dashboard/new/ so test behavior matches the live navigation

Impact

✅ No 308 redirects when creating a new dashboard
✅ Fewer broken dashboard creation flows in redirect-sensitive environments
✅ Tests validate the correct create-dashboard URL

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@ericsong

Copy link
Copy Markdown
Author

Alternatively, we could change the backend

to expose /new instead of /new/ and I think that would work too.

@rusackas
rusackas requested a review from dpgaspar May 29, 2024 16:08
@ericsong

Copy link
Copy Markdown
Author

hey! @rusackas @dpgaspar

just wanted to follow up on this

@mmpepin

mmpepin commented Nov 12, 2024

Copy link
Copy Markdown

Hello @rusackas @dpgaspar. We have the same issue on version 4.0. Is there anything planned to fix this? Thanks!

Copy link
Copy Markdown

Hello everyone, I would like to know if this PR has been reviewed or if an alternative solution has been found? We currently have the same issue (superset version 4.0.6).

@landryb

landryb commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

Alternatively, we could change the backend


to expose /new instead of /new/ and I think that would work too.

fwiw, it should also be possible to add @expose('/new') next to @expose('/new/'), this way both routes work, that's backwards-compatible, and doesn't need fixing in the frontend. I've tested it locally.

landryb added a commit to georchestra/superset-core that referenced this pull request Feb 3, 2025
landryb added a commit to georchestra/superset-core that referenced this pull request Feb 3, 2025
jeanpommier pushed a commit to georchestra/superset-core that referenced this pull request Apr 8, 2025
jeanpommier pushed a commit to georchestra/superset-core that referenced this pull request Apr 10, 2025
@malcolm061990

Copy link
Copy Markdown

HI @dpgaspar
Can please someone review this PR?

@rusackas

Copy link
Copy Markdown
Member

Hi @ericsong! There's been continued community interest in this fix. Are you able to rebase and update this PR? If not, let us know and perhaps someone else from the community could pick it up.

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Dec 17, 2025
const createButton = screen.getByRole('button', { name: /dashboard$/i });
await userEvent.click(createButton);
expect(assignMock).toHaveBeenCalledWith('/dashboard/new');
expect(assignMock).toHaveBeenCalledWith('/dashboard/new/');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The test now expects the create-dashboard navigation to call window.location.assign with /dashboard/new/, but the implementation still navigates to /dashboard/new (without the trailing slash), so this assertion will fail and incorrectly flag the behavior as broken even though the component works as implemented. [logic error]

Severity Level: Minor ⚠️

Suggested change
expect(assignMock).toHaveBeenCalledWith('/dashboard/new/');
expect(assignMock).toHaveBeenCalledWith('/dashboard/new');
Why it matters? ⭐

The component calls navigateTo('/dashboard/new', { assign: true }) (see DashboardTable.tsx), which results in window.location.assign being invoked with '/dashboard/new' (no trailing slash). The test expects '/dashboard/new/' (with trailing slash) and will fail even though the component behavior is correct. Changing the assertion to '/dashboard/new' fixes a real logic mismatch between the test and implementation.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/features/home/DashboardTable.test.tsx
**Line:** 244:244
**Comment:**
	*Logic Error: The test now expects the create-dashboard navigation to call `window.location.assign` with `/dashboard/new/`, but the implementation still navigates to `/dashboard/new` (without the trailing slash), so this assertion will fail and incorrectly flag the behavior as broken even though the component works as implemented.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Subdirectory handling
    The new dashboard route is hardcoded as '/dashboard/new/'. Hardcoded absolute paths bypass the application's makeUrl logic that prefixes application_root in subdirectory deployments. This can break URLs when Superset is served from a non-root path.

  • Possible Routing Bug
    The dashboard menu URL was changed to include a trailing slash to match backend routing.
    Verify this exact path ('/dashboard/new/') matches all backend routes and any reverse proxies or base-path configurations used in deployments. If the app is served under a subpath (BASE_PATH), hardcoding the leading slash may produce incorrect absolute URLs or double-slashes; consider using the project's URL helpers to build the route.

  • Inconsistent URL construction
    The REDIRECTS map mixes raw string paths and calls to makeUrl (e.g., /chart/add vs makeUrl('/sqllab?new=true')). This inconsistency can lead to subtle bugs across environments (trailing-slash behavior, prefixing). Consider normalizing how internal URLs are constructed.

  • Inconsistent URL construction
    Other routes in this file sometimes use makeUrl(...) (e.g. /sqllab?new=true) or ensureAppRoot(...). The new hard-coded string is inconsistent with those approaches and may behave differently when the app is mounted at a non-root path. Search for other occurrences of /dashboard/new across the codebase to ensure all were updated to the trailing-slash form, and consider standardizing how URLs are constructed here.

  • Full-page reload
    The new onClick handler calls navigateTo(..., { assign: true }), which uses window.location.assign and forces a full page reload. In an SPA this discards client-side state and can be less performant/ jarring. Consider using react-router navigation (history.push) or a Link to preserve SPA behavior unless a full reload is intentional.

@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt AI finished reviewing your PR.

@ericsong

Copy link
Copy Markdown
Author

@rusackas updated! the test is passing so I think the codeant review comment is incorrect

@rusackas

rusackas commented Jun 9, 2026

Copy link
Copy Markdown
Member

Thanks @ericsong — there's clear continued demand for this one, sorry it's gone quiet. The branch has drifted back into conflict with master; one more rebase and we'll try to get it reviewed/merged. Also worth considering @landryb's note about adding @expose('/new') alongside /new/ for a backwards-compatible backend fix, if you'd prefer that route.

Setting to draft for now, let me know if you need help driving it forward, I can try to push some commits.

@rusackas
rusackas marked this pull request as draft June 9, 2026 16:55
@rusackas

Copy link
Copy Markdown
Member

@ericsong this keeps biting people behind HTTPS proxies and you've gone quiet, so I'd like to carry it forward on a fresh PR. landryb's idea of just adding @expose('/new') next to /new/ looks cleaner than the frontend changes, so I'll likely take that route, holler if you'd rather finish it yourself.

@rusackas

Copy link
Copy Markdown
Member

Thanks for this @ericsong, and sorry it sat so long! The fix is still valid, so I've adopted it in #41343 (kept you as the author). Going to close this one in favor of that, but holler if you'd rather pick it back up yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard Namespace | Anything related to the Dashboard review:draft size/S size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants